import { Module } from 'vuex'
// 此处加上 `.ts` 后缀报错，具体原因不详
import { ThemeConfigState, RootStateTypes } from '/@/store/interface/index'

/**
 * 2020.05.28 by lyt 优化
 * 修改一下配置时，需要每次都清理 `window.localStorage` 浏览器永久缓存，配置才会生效
 * 哪个大佬有解决办法，欢迎pr，感谢💕！
 */
const themeConfigModule: Module<ThemeConfigState, RootStateTypes> = {
	namespaced: true,
	state: {
		themeConfig: {
			isDrawer: false,
			primary: '#409eff',
			success: '#67c23a',
			info: '#909399',
			warning: '#e6a23c',
			danger: '#f56c6c',
			topBar: '#ffffff',
			menuBar: '#FFFFFF',
			columnsMenuBar: '#545c64',
			topBarColor: '#606266',
			menuBarColor: '#606266',
			columnsMenuBarColor: '#e6e6e6',
			isTopBarColorGradual: false,
			isMenuBarColorGradual: false,
			isColumnsMenuBarColorGradual: false,
			isMenuBarColorHighlight: false,
			isCollapse: false,
			isUniqueOpened: false,
			isFixedHeader: false,
			isFixedHeaderChange: false,
			isClassicSplitMenu: true,
			isLockScreen: false,
			lockScreenTime: 30,
			isShowLogo: true,
			isShowLogoChange: false,
			isBreadcrumb: false,
			isTagsview: true,
			isBreadcrumbIcon: false,
			isTagsviewIcon: false,
			isCacheTagsView: false,
			isSortableTagsView: true,
			isShareTagsView: false,
			isFooter: false,
			isGrayscale: false,
			isInvert: false,
			isIsDark: false,
			isWartermark: false,
			wartermarkText: 'small@小柒',
			tagsStyle: 'tags-style-one',
			animation: 'slide-right',
			columnsAsideStyle: 'columns-round',
			columnsAsideLayout: 'columns-vertical',
			layout: 'classic',
			isRequestRoutes: false,
			globalTitle: 'vue-next-admin',
			globalViceTitle: 'SMALL@小柒',
			globalI18n: 'zh-cn',
			globalComponentSize: '',
		},
	},
	mutations: {
		// 设置布局配置
		getThemeConfig(state: any, data: object) {
			state.themeConfig = data
		},
	},
	actions: {
		// 设置布局配置
		setThemeConfig({ commit }, data: object) {
			commit('getThemeConfig', data)
		},
	},
}

export default themeConfigModule
